home *** CD-ROM | disk | FTP | other *** search
- ;***
- ;
- ;TSSR.ASM
- ;Screen Save and Restore Routines for Turbo Pascal
- ;(C)Copyright Gerard Paul Java 1996
- ;
- ;Interface Source File
- ;
- ;
- ;These routines save and restore the 25x80 screen. These are useful for
- ;pop-up and pop-down windows. This module is not to be run stand-alone.
- ;Used for portability and speed with high-level language programs.
- ;
- ;If these routines are used with 25x40 text screens, two screen pages will
- ;be saved or restored.
- ;
- ;Always call SetTSSRValues before any of the other two routines. Use
- ;SaveScreen before RestoreScreen.
- ;
- ;Assemble with the Borland Turbo Assembler Version 1.0 or later.
- ;
- ;This module is designed to be linked into Turbo Pascal units, and these
- ;routines are intended to be declared in the interface sections. The
- ;routines therefore make use of the FAR call model.
- ;
- ;Declare these procedures in Pascal as:
- ;
- ; procedure SetTSSRValues; external;
- ; procedure SaveScreen(var BuffAddr: ScreenBufferType); external;
- ; procedure RestoreScreen(var BuffAddr: ScreenBufferType); external;
- ;
- ;where ScreenBufferType is declared as:
- ;
- ; type
- ; ScreenBufferType = array[1..2000] of word;
- ;
- ;These procedures make use of the Turbo Pascal Crt unit's CheckSnow variable
- ;to determine whether to execute the snow-elimination code on CGA machines.
- ;
- ;This module requires the Crt unit included in the unit's compilation.
- ;
- ;***
- ;
-
-
- SAVE_SIZE EQU 4000 ;Screen size is 4000 bytes.
- STORE_COUNT EQU 2000 ;Count 2000 times.
- CGA_STAT_REG EQU 3DAH
-
- FALSE EQU 0
- TRUE EQU 1
- boolean EQU BYTE
- pointer EQU DWORD
-
- .MODEL TPASCAL ;TASM Turbo Pascal support.
-
- .DATA
-
- SCREEN_SEG DW ? ;Screen segment
- MONO DB ? ;TRUE if mono.
-
- EXTRN CheckSnow: boolean ;Crt CheckSnow variable.
-
- .CODE
-
-
- ;-----Make routines available to the linker-----
-
- PUBLIC SaveScreen
- PUBLIC RestoreScreen
- PUBLIC SetTSSRValues
-
- ;
- ;-------------------------Procedure SaveScreen-------------------------------
- ;Source segment is DS, pointing to B800h or B000h depending on SetTSSRValues.
- ;Target segment is pointed to by ES, storage buffer pointed to by DI.
- ;---------------------------------------------------------------------------
- ;
- ;procedure SaveScreen(var Buffer: ScreenBufferType);
- ;
- SaveScreen PROC FAR BuffAddr: pointer
- PUSH DS ;Save DS.
- CLD ;Clear direction flag.
- MOV AL,MONO
- MOV AH,CheckSnow
- MOV DS,SCREEN_SEG ;DS points to screen.
- MOV CX,STORE_COUNT ;CX=no of chars in screen.
- MOV DX,CGA_STAT_REG ;Load status register.
- XOR SI,SI ;Point to screen.
- LES DI,BuffAddr ;Load buffer address in DI.
- CMP AL,TRUE ;Mono?
- JE READ_NO_SNOW ;Yes, read with no snow.
- CMP AH,TRUE ;Snow-checking on?
- JNE READ_NO_SNOW ;No, read with no snow.
- R_LWAIT: IN AL,DX ;Get status.
- RCR AL,1 ;Low?
- JC R_LWAIT ;No, loop until so.
- CLI ;Shut off interrupts.
- R_HWAIT: IN AL,DX ;Get status again.
- RCR AL,1 ;High?
- JNC R_HWAIT ;No, loop until so.
- MOVSW ;Move character.
- STI ;Interrupts back on.
- LOOP R_LWAIT ;Loop back.
- JMP R_DONE ;Done.
- READ_NO_SNOW: REP MOVSW ;Move with no snow.
- R_DONE: POP DS ;Restore DS.
- RET ;Return to caller.
- SaveScreen ENDP
-
-
- ;
- ;-------------------------Procedure RestoreScreen---------------------------
- ;Source segment is pointed to by DS, storage buffer pointed to by SI.
- ;Target segment is pointed to by ES, either B800h or B000h, depending on
- ;Screen_Seg, returned by SetTSSRValues.
- ;---------------------------------------------------------------------------
- ;
- ;procedure RestoreScreen(var BuffAddr: ScreenBufferType);
- ;
- RestoreScreen PROC FAR BuffAddr: pointer
- CLD ;Clear direction flag.
- MOV AL,MONO
- MOV AH,CheckSnow
- INIT_LOAD: MOV ES,SCREEN_SEG ;Put screen segment in ES.
- MOV CX,STORE_COUNT ;Size to restore.
- MOV DX,CGA_STAT_REG ;Load CGA status register.
- XOR DI,DI ;Point to init screen postn.
- LDS SI,BuffAddr ;Load buffer address.
- CMP AL,TRUE ;Mono?
- JE WRITE_NO_SNOW ;Yes, no snow.
- CMP AH,TRUE ;Snow-checking on?
- JNE WRITE_NO_SNOW ;No, no snow, store bytes.
- W_LWAIT: IN AL,DX ;Get status.
- RCR AL,1 ;Low?
- JC W_LWAIT ;No, loop until so.
- CLI ;Shut off interrupts.
- W_HWAIT: IN AL,DX ;Get status again.
- RCR AL,1 ;High?
- JNC W_HWAIT ;No, loop until so.
- MOV_TO_SCREEN: MOVSW ;Move character to screen.
- STI ;Interrupts back on.
- LOOP W_LWAIT ;Do it CX times.
- JMP W_DONE ;Done.
- WRITE_NO_SNOW: REP MOVSW ;Move with no snow.
- W_DONE: RET ;Return to caller.
- RestoreScreen ENDP
-
- ;
- ;----------------------------------------------------------------------------
- ;SetTSSRValues: Determines the proper screen segment to operate on and sets a
- ;flag if the system is equipped with a CGA, for use in case it "snows". This
- ;routine must be called before SaveScreen, which must be called before
- ;RestoreScreen. Calling any routine without the required calls produces
- ;unpredictable results.
- ;----------------------------------------------------------------------------
- ;
- ;procedure SetTSSRValues;
- ;
- SetTSSRValues PROC FAR
- MOV AH,15 ;Retreive video mode.
- INT 10H
- CMP AL,7 ;Mono?
- JE MONO_SETUP ;Yes, get segment.
- COLOR_SETUP: MOV SCREEN_SEG,0B800H
- MOV MONO,FALSE
- JMP DONE
- MONO_SETUP: MOV SCREEN_SEG,0B000H
- MOV MONO,TRUE
- DONE: RET ;Return to caller.
- SetTSSRValues ENDP
-
- END
-
-